import itemOption from "./sensory"
const typeChartInit=(elm, data, items,echarts)=> {
    const myChart = echarts.init(document.getElementById(elm));
    const sData=[];
    const indicators=[];
    for(let i of items){
        const item=itemOption['item'+i];
        indicators.push({name:item.name,max:item.max});
        sData.push(data["score"+i]);
    }
    const option = {
        color: ['#FFA800'],
        legend: {show:false},
        radar: [
            {
                indicator:  indicators,
                center: ['50%', '50%'],
                radius: 90,                
                startAngle: 90,                
                splitNumber: 5,
                shape: 'circle',                
                axisName: {
                    formatter: '{value}',
                    color: '#333333'
                },
                splitArea: {
                    areaStyle: {
                        color: ['#EFC59E', '#FFF8D8', '#FFFDEC', '#FFFEF6','#FFFFFF'],
                        // shadowColor: 'rgba(0, 0, 0, 0.2)',
                        // shadowBlur: 10
                    }
                },
                axisLine: {
                    lineStyle: {
                        color: '#D7C5AB'
                    }
                },
                splitLine: {
                    lineStyle: {
                        color: '#D7C5AB',
                        type:"dashed"
                    }
                }
            },
        ],
        series: [
            {
                type: 'radar',
                emphasis: {
                    lineStyle: {
                        width:4
                    }
                },
                label:{
                  show:true,
                  fontSize:16,
                  fontWeight:"bold"
                },
                data: [
                    {
                        value: sData,
                        name: 'Data A',
                        areaStyle: {
                          color: 'rgba(255, 153, 0, 0.5)'
                        }
                    }                    
                ]
            },

        ]
    };
    // 使用刚指定的配置项和数据显示图表。
    myChart.setOption(option);
}
export default typeChartInit;